#Alexander F. Gazmararian
#afg2@princeton.edu

#load data from national youth survey
g <- readRDS("data/NatYouthQual.rds")

#load packages
library(tidyverse)
library(modelsummary)

#load functions 
source("code/fun/book_theme.r")
source("code/fun/savefig.r")
source("code/fun/fix_txt.r")

# Prepare coefficient names
source("code/fun/coefnames4tables.r")
coefnames <- c("externalcause"="Treatment: External Cause of Dislocation", coefnames)

# Estimate model for online appendix ----
f.base <- y ~ age + Female + PartySummary + Black + Hispanic + CollegeIntend + income5 + employfull

g$gov_support_scale <- as.numeric(g$gov_support)

m <- list()
m[["Scale"]] <- lm(update(f.base, gov_support_scale ~ externalcause + youth_block + .), g)
m[["Binary"]] <- lm(update(f.base, gov_support_i ~ externalcause + youth_block + .), g)
file <- "tables/ch3/ols_expectassist.txt"
modelsummary(
  m,
  vcov = "HC2",
  stars = c("*"=.1,"**"=.05,"***"=.01),
  escape = FALSE,
  coef_map = coefnames,
  gof_map = c("nobs","adj.r.squared"),
  output = "latex"
) %>%
  cat(., file = file)
fix_txt(file)
